{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b0f2273e-baaf-4c91-b85d-139c89de1629",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pymysql\n",
    "from pymysql import Connection\n",
    "from pymysql.cursors import DictCursor\n",
    "def get_connection(autocommit: bool = True) -> Connection:\n",
    "    db_conf = {\n",
    "            \"host\": \"192.168.98.55\",\n",
    "            \"port\": 4000,\n",
    "            \"user\": \"dataware_house_testUser\",\n",
    "            \"password\": \"IlGiUL2qcdqckoIzj6c4\",\n",
    "            \"database\": \"dataware_house_test\",\n",
    "            \"autocommit\": autocommit,\n",
    "            # \"cursorclass\": DictCursor,\n",
    "        }\n",
    "    conn:Connection = pymysql.connect(**db_conf)\n",
    "    return conn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "84d1c4b7-a3f8-40b3-b1e5-a27ef892090e",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_18568\\726147944.py:4: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.\n",
      "  df = pd.read_sql(sql, conn)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>keyid</th>\n",
       "      <th>title</th>\n",
       "      <th>author</th>\n",
       "      <th>pub_year</th>\n",
       "      <th>vol</th>\n",
       "      <th>num</th>\n",
       "      <th>begin_page</th>\n",
       "      <th>end_page</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00001563A256494FD2D2D12043101835F104A</td>\n",
       "      <td>经济新常态下上市公司财务绩效提升的建议</td>\n",
       "      <td>赵瑞娟[1]</td>\n",
       "      <td>2019</td>\n",
       "      <td></td>\n",
       "      <td>22</td>\n",
       "      <td>85</td>\n",
       "      <td>86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00001563C13E0F38FFDDA8B02B22E4E828031</td>\n",
       "      <td>2018年天津市固定资产投资情况及走势展望</td>\n",
       "      <td>王铮[1]</td>\n",
       "      <td>2019</td>\n",
       "      <td></td>\n",
       "      <td>22</td>\n",
       "      <td>120</td>\n",
       "      <td>121</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0000156EEEEC891C0D214843622C3DD337BE5</td>\n",
       "      <td>浅谈X集团公司如何更加合理管控投资公司</td>\n",
       "      <td>孔莉[1]</td>\n",
       "      <td>2019</td>\n",
       "      <td></td>\n",
       "      <td>22</td>\n",
       "      <td>23</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00001574811B57A1F8D6D804545393A32CFF4</td>\n",
       "      <td>浅析新时期下会计账务处理的问题策略</td>\n",
       "      <td>郜东梅[1]</td>\n",
       "      <td>2021</td>\n",
       "      <td></td>\n",
       "      <td>15</td>\n",
       "      <td>166</td>\n",
       "      <td>168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0000158146778C5242484151970CD9A0B512D</td>\n",
       "      <td>国有企业人才引进和流失的因素及防范策略</td>\n",
       "      <td>孙宾[1]</td>\n",
       "      <td>2021</td>\n",
       "      <td></td>\n",
       "      <td>31</td>\n",
       "      <td>91</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15750</th>\n",
       "      <td>00001J1W6DDO2JDW6HC9Q</td>\n",
       "      <td>试论新常态下我国经济发展的路径选择</td>\n",
       "      <td>唐可[1]</td>\n",
       "      <td>2018</td>\n",
       "      <td></td>\n",
       "      <td>19</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15751</th>\n",
       "      <td>00001J1W6DDO2JDW6HCHQ</td>\n",
       "      <td>浅谈商超连锁行业税务筹划对纳税义务的影响</td>\n",
       "      <td>郝艳军[1]</td>\n",
       "      <td>2018</td>\n",
       "      <td></td>\n",
       "      <td>19</td>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15752</th>\n",
       "      <td>00001J1W6DDO2JDW6HCPQ</td>\n",
       "      <td>新时代如何看待粮食经济发展的压力与机遇</td>\n",
       "      <td>陈祥利[1]</td>\n",
       "      <td>2018</td>\n",
       "      <td></td>\n",
       "      <td>19</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15753</th>\n",
       "      <td>00001J1W6DDO2JDW6HD1Q</td>\n",
       "      <td>我国便利店行业SCP分析</td>\n",
       "      <td>杜军[1]</td>\n",
       "      <td>2018</td>\n",
       "      <td></td>\n",
       "      <td>19</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15754</th>\n",
       "      <td>00001J1W6DDO2JDW6HD9Q</td>\n",
       "      <td>新时代流通变革与媒体创新论坛暨“中国流通媒体联盟”成立大会在京召开</td>\n",
       "      <td>本刊编辑部</td>\n",
       "      <td>2018</td>\n",
       "      <td></td>\n",
       "      <td>19</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>15755 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                       keyid  \\\n",
       "0      00001563A256494FD2D2D12043101835F104A   \n",
       "1      00001563C13E0F38FFDDA8B02B22E4E828031   \n",
       "2      0000156EEEEC891C0D214843622C3DD337BE5   \n",
       "3      00001574811B57A1F8D6D804545393A32CFF4   \n",
       "4      0000158146778C5242484151970CD9A0B512D   \n",
       "...                                      ...   \n",
       "15750                  00001J1W6DDO2JDW6HC9Q   \n",
       "15751                  00001J1W6DDO2JDW6HCHQ   \n",
       "15752                  00001J1W6DDO2JDW6HCPQ   \n",
       "15753                  00001J1W6DDO2JDW6HD1Q   \n",
       "15754                  00001J1W6DDO2JDW6HD9Q   \n",
       "\n",
       "                                   title  author pub_year vol num begin_page  \\\n",
       "0                    经济新常态下上市公司财务绩效提升的建议  赵瑞娟[1]     2019      22         85   \n",
       "1                  2018年天津市固定资产投资情况及走势展望   王铮[1]     2019      22        120   \n",
       "2                    浅谈X集团公司如何更加合理管控投资公司   孔莉[1]     2019      22         23   \n",
       "3                      浅析新时期下会计账务处理的问题策略  郜东梅[1]     2021      15        166   \n",
       "4                    国有企业人才引进和流失的因素及防范策略   孙宾[1]     2021      31         91   \n",
       "...                                  ...     ...      ...  ..  ..        ...   \n",
       "15750                  试论新常态下我国经济发展的路径选择   唐可[1]     2018      19         10   \n",
       "15751               浅谈商超连锁行业税务筹划对纳税义务的影响  郝艳军[1]     2018      19          7   \n",
       "15752                新时代如何看待粮食经济发展的压力与机遇  陈祥利[1]     2018      19          5   \n",
       "15753                       我国便利店行业SCP分析   杜军[1]     2018      19          4   \n",
       "15754  新时代流通变革与媒体创新论坛暨“中国流通媒体联盟”成立大会在京召开   本刊编辑部     2018      19          3   \n",
       "\n",
       "      end_page  \n",
       "0           86  \n",
       "1          121  \n",
       "2           24  \n",
       "3          168  \n",
       "4           93  \n",
       "...        ...  \n",
       "15750       11  \n",
       "15751        9  \n",
       "15752        6  \n",
       "15753        5  \n",
       "15754        3  \n",
       "\n",
       "[15755 rows x 8 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "sql = \"select keyid,title,author,pub_year,vol,num,begin_page,end_page from dataware_house_test.base_fact_title_journal WHERE gch = '88422A'\"\n",
    "with get_connection(autocommit=False) as conn:\n",
    "    df = pd.read_sql(sql, conn)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "0d6bef93-d47c-496f-a052-71f48af55c19",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'keyid': '00001JD0M9C84J5X69R', 'title': 'IO_3^--I^--罗丹明B-乳化剂OP体系测定水样中生化需氧量', 'author': '沙鸥[1];马卫兴[1];刘英红[1];郭妍[2]', 'pub_year': '2010', 'vol': '38', 'num': '1', 'begin_page': '148', 'end_page': '148'}, {'keyid': '00001JV1MPD88JP1MFDO1', 'title': '基于神经化学分析研究炮制对人参和西洋参药性的影响', 'author': '黄鑫[1];王妮[1];张娜[1];越皓[1];刘淑莹[1,2]', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '957', 'end_page': '963'}, {'keyid': '00001JV1MPD88JP1MFDO2', 'title': '木兰花碱的荧光性质及其在中药分析中的应用研究', 'author': '曹津津[1,2];孙启瑞[2];李文红[3];宋冉冉[2];曹倩玉[2,4];王可[4];魏永巨[1,2]', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '950', 'end_page': '956'}, {'keyid': '00001JV1MPD88JP1MFDO3', 'title': '沃特世发布中药Q-marker“时”-“空”维度全新解决方案', 'author': '', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '949', 'end_page': '949'}, {'keyid': '00001JV1MPD88JP1MFDO4', 'title': '基于近红外光谱的红提维生素C含量、糖度及总酸含量无损检测方法', 'author': '高升[1];王巧华[1,2];李庆旭[1];施行[1]', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '941', 'end_page': '949'}, {'keyid': '00001JV1MPD88JP1MFDO5', 'title': '高场不对称波形离子迁移谱分离检测3种二甲苯同分异构体', 'author': '王晗[1,2];刘友江[1];李山[1];徐青[1];胡俊[1,2];马贺[1,2];陈池来[1]', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '933', 'end_page': '940'}, {'keyid': '00001JV1MPD88JP1MFDO6', 'title': '基于电喷雾-四极杆-飞行时间质谱的神经节苷脂的结构解析', 'author': '张华林[1];郭志谋[2,3];王联芝[1];金高娃[2,3];邹丽红[4];吕园园[4];马明辉[4];闫竞宇[2,3];段正超[1];梁鑫淼[2,3]', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '925', 'end_page': '932'}, {'keyid': '00001JV1MPD88JP1MFDO7', 'title': '超高分辨质谱研究离子源内气体氛围对电喷雾电离呼出气的影响', 'author': '杜睿[1,2];张羽玲[1,2];曾嘉发[1,2];方明亮[3];Sasho Gligorovski[4];周振[1,2];李雪[1,2]', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '916', 'end_page': '924'}, {'keyid': '00001JV1MPD88JP1MFDO8', 'title': '大气气溶胶硝酸盐中稳定氮氧同位素比值测定', 'author': '赵祝钰[1];曹芳[1];张雯淇[1];翟晓瑶[1];方言[1];范美益[1];章炎麟[1]', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '907', 'end_page': '915'}, {'keyid': '00001JV1MPD88JP1MFDO9', 'title': '基于核酸外切酶Ⅲ辅助双循环等温信号放大的高灵敏Hg^(2+)传感方法研究', 'author': '张何[1];王青[1];杨梅[1];傅昕[1]', 'pub_year': '2019', 'vol': '47', 'num': '6', 'begin_page': '899', 'end_page': '906'}]\n"
     ]
    }
   ],
   "source": [
    "result = df.to_dict(orient='records')\n",
    "print(result[:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "5fb39ec2-b907-48ef-94a2-d586dfcb3d71",
   "metadata": {},
   "outputs": [],
   "source": [
    "documents = [dict_data[\"title\"] for dict_data in result]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "2c19ae59-8981-4fd2-8c04-4360f929f8ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "import jieba\n",
    "from rapidfuzz import process, fuzz\n",
    "# 分词函数\n",
    "def segment(text):\n",
    "    return list(jieba.cut(text))\n",
    "\n",
    "# 搜索函数\n",
    "def search(query):\n",
    "    # 对查询字符串进行分词\n",
    "    segmented_query = \" \".join(segment(query))\n",
    "    results = process.extract(segmented_query, documents, scorer=fuzz.WRatio, limit=20)\n",
    "    return results  # 根据需要调整阈值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "61fa074d-7bb5-4ffb-9735-1a265ddc87eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('水中氨氮的酶法测定', 41.53846153846154, 4532),\n",
       " ('烷基多苷的分析测定', 41.53846153846154, 10290),\n",
       " ('极谱法测定光气', 40.0, 7958),\n",
       " ('溴含量的快速光度测定', 38.57142857142858, 6390),\n",
       " ('人尿中克仑特罗的测定', 38.57142857142858, 8904),\n",
       " ('胆红素的间接光度测定', 38.57142857142858, 8939),\n",
       " ('胆红素的间接极谱测定', 38.57142857142858, 9040),\n",
       " ('巴丹的间接极谱法测定', 38.57142857142858, 9246),\n",
       " ('碘的凝胶色谱测定方法', 38.57142857142858, 9767),\n",
       " ('叶绿素的伏安行为和测定', 36.0, 1426),\n",
       " ('微量硼的荧光光度测定法', 36.0, 1628),\n",
       " ('钢铁中微量铝的荧光测定', 36.0, 2539),\n",
       " ('荧光素钠荧光寿命的测定', 36.0, 2606),\n",
       " ('高含量铁的示波极谱测定', 36.0, 3012),\n",
       " ('稀土镁中间合金中稀土、镁的比色测定', 36.0, 6213),\n",
       " ('赤霉酸的方波伏安法测定', 36.0, 6394),\n",
       " ('淀粉磷酸酯结合磷的测定', 36.0, 6541),\n",
       " ('痕量硒的催化褪色法测定', 36.0, 7043),\n",
       " ('土壤全锗的催化极谱测定', 36.0, 7606),\n",
       " ('植酸中无机磷的极谱测定', 36.0, 8092)]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "search(\"氧化钴中钴的电解分离和钠、钙、镁的测定\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "37b41b34-c5e5-48c1-a3d5-fbefe1247b04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'keyid': '00001JV1MPD81JHWM9D80',\n",
       " 'title': '卡维地洛和美托洛尔治疗高血压效果及对糖脂代谢的影响',\n",
       " 'author': '罗丽琴[1]',\n",
       " 'pub_year': '2019',\n",
       " 'vol': '25',\n",
       " 'num': '26',\n",
       " 'begin_page': '54',\n",
       " 'end_page': '56'}"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result[15140]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "e7d405ed-b562-4d31-822d-ebcdec9efd30",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pymysql\n",
    "from pymysql import Connection\n",
    "from pymysql.cursors import DictCursor\n",
    "def get_connection2(autocommit: bool = True) -> Connection:\n",
    "    db_conf = {\n",
    "            \"host\": \"192.168.98.55\",\n",
    "            \"port\": 4000,\n",
    "            \"user\": \"collect_threeUser\",\n",
    "            \"password\": \"84009ED68DE89F6167BAB420A8BE9243\",\n",
    "            \"database\": \"collect_three\",\n",
    "            \"autocommit\": autocommit,\n",
    "            # \"cursorclass\": DictCursor,\n",
    "        }\n",
    "    conn:Connection = pymysql.connect(**db_conf)\n",
    "    return conn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "5e80e9c7-ac0e-41a1-afb0-79bd52bb4465",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_5584\\3233635878.py:3: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.\n",
      "  df1 = pd.read_sql(sql, conn)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>腹腔镜手术对胃癌患者血清肿瘤标志物及炎症指标的影响</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>支气管肺炎合并呼吸衰竭对肠黏膜屏障的损伤研究</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>红乌合剂联合化疗改善乳腺癌的近期疗效与生存质量的研究</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>19例护理不良事件原因分析与管理对策探讨</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>慢性病防治指南的评价研究</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56760</th>\n",
       "      <td>睢宁县2011～2012年涂阳肺结核患者就诊、发现延迟影响因素调查分析</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56761</th>\n",
       "      <td>宫腔镜检查对妇女绝经后子宫出血的诊断价值</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56762</th>\n",
       "      <td>手足口病的护理体会</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56763</th>\n",
       "      <td>引起视疲劳病因分析及防治</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56764</th>\n",
       "      <td>CT检查在老年急性胰腺炎患者临床诊断和治疗中的辅助作用</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>56765 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                     title\n",
       "0                腹腔镜手术对胃癌患者血清肿瘤标志物及炎症指标的影响\n",
       "1                   支气管肺炎合并呼吸衰竭对肠黏膜屏障的损伤研究\n",
       "2               红乌合剂联合化疗改善乳腺癌的近期疗效与生存质量的研究\n",
       "3                     19例护理不良事件原因分析与管理对策探讨\n",
       "4                             慢性病防治指南的评价研究\n",
       "...                                    ...\n",
       "56760  睢宁县2011～2012年涂阳肺结核患者就诊、发现延迟影响因素调查分析\n",
       "56761                 宫腔镜检查对妇女绝经后子宫出血的诊断价值\n",
       "56762                            手足口病的护理体会\n",
       "56763                         引起视疲劳病因分析及防治\n",
       "56764          CT检查在老年急性胰腺炎患者临床诊断和治疗中的辅助作用\n",
       "\n",
       "[56765 rows x 1 columns]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "with get_connection2(autocommit=False) as conn:\n",
    "    sql = \"SELECT title FROM `collect_three`.`cboa_latest` WHERE `gch` = '90953A'\"\n",
    "    df1 = pd.read_sql(sql, conn)\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bf39be36-2d08-473c-9df3-64d0fab990f5",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'df' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[1], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtqdm\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m tqdm\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m item \u001b[38;5;129;01min\u001b[39;00m  tqdm(df\u001b[38;5;241m.\u001b[39mto_dict(orient\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrecords\u001b[39m\u001b[38;5;124m'\u001b[39m)):\n\u001b[0;32m      3\u001b[0m     result1 \u001b[38;5;241m=\u001b[39m search(item[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtitle\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n",
      "\u001b[1;31mNameError\u001b[0m: name 'df' is not defined"
     ]
    }
   ],
   "source": [
    "from tqdm import tqdm\n",
    "for item in  tqdm(df.to_dict(orient='records')):\n",
    "    result1 = search(item[\"title\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d7210b86-3a1b-4c31-a208-bd92c5204965",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用 range 生成整数序列\n",
    "result = [x / 100 for x in range(90, 100, 1)]\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1d7b12a9-6d9c-4dfd-94d4-7dd1d616c835",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result = [x / 100 for x in range(50, 90, 5)]\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a514cb81-5685-4b98-b7ca-da2fd39ef206",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cboa_list=[]\n",
    "[cboa_list[cc:cc + 1000] for cc in range(0, len(cboa_list), 1000)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fed35af2-1804-40a6-8341-e4a4a481759b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
